package mvc
{
	import flash.display.Sprite;
	import flash.events.Event;

	public class AnalogClock extends AbstractClockView
	{
		private var _face:Sprite;
		private var _hourHand:Sprite;
		private var _minuteHand:Sprite;
		private var _secondHand:Sprite;
		
		public function AnalogClock(data:ClockData)
		{
			super(data);
			
			_face = new Sprite;
			_face.graphics.lineStyle(0,0x000000,1);
			_face.graphics.drawCircle(0,0,100);
			this.addChild(_face);
			
			_hourHand = new Sprite;
			_hourHand.graphics.lineStyle(5,0x000000,1);
			_hourHand.graphics.lineTo(0,-50);
			this.addChild(_hourHand);
			
			_minuteHand = new Sprite;
			_minuteHand.graphics.lineStyle(2,0x000000,1);
			_minuteHand.graphics.lineTo(0,-80);
			this.addChild(_minuteHand);
			
			_secondHand = new Sprite;
			_secondHand.graphics.lineStyle(0,0x000000,1);
			_secondHand.graphics.lineTo(0,-80);
			this.addChild(_secondHand);
			
			draw();
		}
		
		override protected function draw(event:Event=null):void{
			var time:Time = _data.time;
			
			_hourHand.rotation = 30*time.hour + 30*time.minute/60;
			_minuteHand.rotation = 6*time.hour + 6*time.minute/60;
			_secondHand.rotation = 6*time.second;
		}
		
	}
}